import unittest
from django.test import TestCase
# from moduleZkk import Calculator
from sign.models import Event, Guest

# class ModuleTest(unittest.TestCase):
#     def setUp(self):
#         self.cal = Calculator(8, 4)
#
#     def tearDown(self):
#         pass
#
#     def test_add(self):
#         result = self.cal.add()
#         self.assertEqual(result, 12)
#
#     def test_sub(self):
#         result = self.cal.sub()
#         self.assertEqual(result, 4)
#
#     def test_mul(self):
#         result = self.cal.mul()
#         self.assertEqual(result, 32)
#
#     def test_div(self):
#         result = self.cal.div()
#         self.assertEqual(result, 2)


# if __name__ == "__main__":
#     suite = unittest.TestSuite()
#     suite.addTest(ModuleTest('test_add'))
#     suite.addTest(ModuleTest('test_sub'))
#     suite.addTest(ModuleTest('test_mul'))
#     suite.addTest(ModuleTest('test_div'))
#
#     runner = unittest.TextTestRunner()
#     runner.run(suite)


class ModelTest(TestCase):

    def setUp(self):
        Event.objects.create(id=1, name='oneplus 3 event', status=True, limit=2000, address='shenzhen', start_time='2018-08-31 14:22:21')
        Guest.objects.create(id=1, event_id=1, realname='yuexiaoting', phone='13521111111', email='yuexiaoting@loveerkang', sign=False)

    def test_event_models(self):
        result = Event.objects.get(name='oneplus 3 event')
        self.assertEqual(result.address, 'shenzhen')
        self.assertTrue(result.status)

    def test_guest_models(self):
        result = Guest.objects.get(phone='13521111111')
        self.assertEqual(result.realname, "yuexiaoting")
        self.assertFalse(result.sign)


